function AttFjGd() {
    this.form = this.InitForm();
    this.tab = this.InitTab();
    this.table = null;

    this.InitGrid();

    $("#year").val($("#hidyear").val());
    $("#month").val($("#hidmonth").val());
    this.form.render('select');

    this.InitOrg();
}


AttFjGd.prototype.InitOrg = function () {
    var comboboxm = $("#orgid").ligerComboBox({
        valueField: 'orgid',
        textField: 'orgname',
        selectBoxWidth: 250,
        selectBoxHeight: 250,
        treeLeafOnly: false,
        valueFieldID: "hid",
        tree: {
            url: '../common/get_org_list?orgtype=0',
            checkbox: false,
            nodeWidth: 150,
            ajaxType: 'get',
            idFieldName: 'orgid',
            textFieldName: "orgname",
            idField: "orgid",
            parentIDField: "orgparentid"
        },
        onSelected: function (orgid, orgname) {// id为空值，name为选择的值
            $("#hidorgid").val(orgid);
            vTransPay.searchlist();
        },
        width: 250
    });
    return comboboxm;
}

AttFjGd.prototype.InitTab = function () {
    var element;
    layui.use('element', function () {
        element = layui.element;

        element.on('tab(tabcontent)', function (data) {
            if (data.index == 1) {

            } else {
                //$("#hidorgid").val(0);
                //$("#hidorgsummaryid").val(0);
                //this.InitTableByBt(0,0);
            }
        });

    });
    return element;
}

AttFjGd.prototype.InitForm = function () {
    var form;
    layui.use('form', function () {
        form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.on('select(year)', function (data) {
            $("#hidyear").val(data.value);
            form.render('select');
            vTransPay.searchlist();
        });
        form.on('select(month)', function (data) {
            $("#hidmonth").val(data.value);
            form.render('select');
            vTransPay.searchlist();
        });
        form.on('select(status)', function (data) {
            $("#hidstatus").val(data.value);
            form.render('select');
            vTransPay.searchlist();
        });


        form.render();
    });
    return form;
}
AttFjGd.prototype.OpTab = function (tabindex, obj) {
    this.tab.tabChange('tabcontent', tabindex);
}

AttFjGd.prototype.InitGrid = function () {
    var _this = this;
    window.liger.remove("orgsuylist");
    if (_this.grid == null) {
        _this.grid = $("#orgsuylist").ligerGrid({
            checkbox: true,
            columns: [

                //{ display: '序号', width: 80, name: 'rowNum' },
                {display: '机构名称', width: 250, align: 'left', name: 'orgname', id: "orgname"},
                {display: '年', width: 100, name: 'year'},
                {
                    display: '季度', width: 100, name: 'quarter', render: function (rowdata, rowindex, value) {
                        var month = rowdata.month;
                        var quarter = rowdata.quarter;
                        var str = '';
                        switch (quarter) {
                            case null:
                            case '':
                            case undefined:
                                if (month == "1" || month == "2" || month == "3") {
                                    str = "第一季度";
                                }
                                if (month == "4" || month == "5" || month == "6") {
                                    str = "第二季度";
                                }
                                if (month == 7 || month == 8 || month == 9) {
                                    str = "第三季度";
                                }
                                if (month == 10 || month == 11 || month == 12) {
                                    str = "第四季度";
                                }
                                break;
                            case 1:
                                str = "第一季度";
                                break;
                            case 2:
                                str = "第二季度";
                                break;
                            case 3:
                                str = "第三季度";
                                break;
                            case 4:
                                str = "第四季度";
                                break;
                        }
                        return str;
                    }
                },
                {display: '月份', width: 100, name: 'month'},
                {
                    display: '部门人数', width: 100, name: 'orgsummaryid', render: function (rowdata, rowindex, value) {
                        var id = rowdata.orgsummaryid;
                        var str = '';
                        if (id == null || id == '' || id == undefined) {
                            console.log(1);
                            var percount = rowdata.usercount;
                            str = percount;
                        } else {
                            console.log(2);
                            var realusercount = rowdata.realusercount;
                            str = realusercount;
                        }
                        return str;
                    }
                },
                {
                    display: '状态', width: 120, name: 'status', render: function (rowdata, rowindex, value) {
                        var status = rowdata.status;
                        if (!rowdata.usercount||rowdata.usercount <= 1) {
                            return '';
                        }
                        var str = '';
                        switch (status) {
                            case null:
                            case '':
                            case undefined:
                                str = "未填报";
                                break;
                            case 0:
                                str = '<span style="color:#B8E986">填报<span>';
                                break;
                            case 1:
                                str = "提交";
                                break;
                            case 2:
                                str = "归档";
                                break;
                            case 3:
                                str = "驳回";
                                break;
                            case 4:
                                str = "审核通过";
                                break;
                        }
                        return str;
                    }
                },
                {
                    display: '操作', width: 100, name: 'userid', render: function (rowdata, rowindex, value) {
                        var html = '';
                        if (rowdata.status != null && typeof(rowdata.status) != 'undefined') {
                            html += ' <img class="btn-img" onclick="vTransPay.SkipDetail(' + rowdata.orgid + ',' + rowdata.orgsummaryid + ',\'' + rowdata.orgname + '\',' + rowdata.year + ',' + rowdata.month + ')" src="' + ctxStatic + '/images/button/detail.png" lay-event="detail" alt="详情" title="详情">';
                        }
                        if (rowdata.usercount - 1 > 0 && typeof(rowdata.status) == 'undefined') {

                            html += ' <img class="btn-img" onclick="vTransPay.createatttb(' + rowdata.orgid + ',' + rowdata.year + ',' + rowdata.month + ')" src="' + ctxStatic + '/images/index/yaosu.png" lay-event="shengcheng" alt="计算补助" title="计算补助">';
                        }
                        if (rowdata.status == 1 || rowdata.status == 0) {
                            html += '<img class="btn-img" onclick="vTransPay.updatestatus(' + rowdata.orgsummaryid + ',2)" src="' + ctxStatic + '/images/button/guidang.png" lay-event="guidang" alt="归档" title="归档">';
                            // html += '<img class="btn-img" onclick="vTransPay.updatestatus(' + rowdata.orgsummaryid + ',3)" src="' + ctxStatic + '/images/button/bohui.png" lay-event="bohui" alt="驳回" title="驳回">';
                        }
                        if (rowdata.status != null && typeof(rowdata.status) != 'undefined') {
                            if ($("#hidAdmin").val() == "true") {
                                html += '<img class="btn-img" onclick="vTransPay.updatestatus(' + rowdata.orgsummaryid + ',3)" src="' + ctxStatic + '/images/button/bohui.png" lay-event="bohui" alt="驳回" title="驳回">';
                            }
                        }
                        return html;
                    }
                }
            ],
            pageSize: 30,
            url: "get_org_tran_list" + '?time=' + new Date().getTime(),
            delayLoad: false,            //初始化时是否加载,为true时,不加载,为false时,则加载
            sortName: null,
            dataAction: 'server',
            parms: {
                Method: "",
                year: $("#hidyear").val(),
                month: $("#hidmonth").val(),
                orgid: $("#hidorgid").val()
            },
            sortOrder: null,
            sourceObj: _this.grid,
            root: 'items',                       //数据源字段名
            record: 'countRecord',                    //数据源记录数字段名
            pageParmName: 'CurrentPage',               //页索引参数名，(提交给服务器)
            pagesizeParmName: 'PageSize',        //页记录数参数名，(提交给服务器)
            data: {},
            width: "100%",

            height: '100%',
            heightDiff: 0,
            rowHeight: 28,
            onBeforeCheckRow: function (checked, data, rowid, rowdata) {
                if (data.status == 1) {
                    // return true;
                }
                else {
                    //$("#"+rowid).attr("title","该部门未提交");
                    //top.mylayui.msg('该部门未提交数据', {icon: 0});
                    // return false;
                }
            },
            onBeforeCheckAllRow: function (checked, element) {
                //alert(checked);
                // return false;
            },
            onSuccess: function (rowdata, rowindex) {
                if (rowdata.status > 0) {
                    alert(rowdata.msg)
                }
            },
            alternatingRow: true,
            border: 0,
            usePager: false,
            tree: {
                columnId: "orgname",
                idField: "orgid",
                parentIDField: "orgparentid"

            }
        })
    }
}


AttFjGd.prototype.InitOrgSuyTable = function () {
    var table;
    var _this = this;
    layui.use('table', function () {
        table = layui.table;
        table.render({
            elem: '#orgsuylist'
            , height: $(window).height() - 230
            , url: 'get_org_summary_list' // 数据接口
            , page: true // 开启分页
            , limit: 30
            , id: 'orgsuylist'
            , method: "post"
            , cols: [[ // 表头
                {type: 'checkbox'}
                //{field : 'rowNum',title : '序号',width : 70,align : 'center'}
                , {field: 'orgname', title: '单位名称', width: 250, align: 'center'}
                , {field: 'year', title: '年', width: 100, align: 'center'}
                , {field: 'quarter', title: '季度', width: 120, align: 'center'}
                , {field: 'month', title: '月份', width: 120, align: 'center'}
                , {field: 'usercount', title: '部门人数', width: 100, align: 'center'}
                , {field: 'status', title: '状态', width: 120, align: 'center'}
                , {title: '操作', width: 150, align: 'center', toolbar: '#operateorgsuy'}
            ]]
            , request: {
                type: 'post'
            }
            , page: false
            , where: {
                year: $("#hidyear").val(),
                month: $("#hidmonth").val(),
                status: $("#hidstatus").val()
            }
            , even: true //开启隔行背景
            , done: function (res, page, count) {
                var dataarr = res.data;
                $("[data-field='status']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        switch (text) {
                            case null:
                                $(this).text("未填报");
                                break;
                            case '':
                                $(this).text("未填报");
                                break;
                            case '0':
                                $(this).text("填报");
                                break;
                            case '1':
                                $(this).text("提交");
                                break;
                            case '2':
                                $(this).text("归档");
                                break;
                            case '3':
                                $(this).text("驳回");
                                break;
                            case  '4':
                                $(this).text("审核通过");
                                break;

                        }
                    }
                })

                $("[data-field='sfqq']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        if (text == "0") {
                            $(this).text("否");
                        }
                        else {
                            $(this).text("是");
                        }
                    }
                })

                $("[data-field='quarter']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        switch (text) {
                            case null:
                            case '':
                                var month = dataarr[index - 1].month;
                                if (month == 1 || month == 2 || month == 3) {
                                    $(this).text("第一季度");
                                }
                                if (month == 4 || month == 5 || month == 6) {
                                    $(this).text("第二季度");
                                }
                                if (month == 7 || month == 8 || month == 9) {
                                    $(this).text("第三季度");
                                }
                                if (month == 10 || month == 11 || month == 12) {
                                    $(this).text("第四季度");
                                }
                                break;
                            case '1':
                                $(this).text("第一季度");
                                break;
                            case '2':
                                $(this).text("第二季度");
                                break;
                            case '3':
                                $(this).text("第三季度");
                                break;
                            case '4':
                                $(this).text("第四季度");
                                break;
                        }
                    }
                })


                // var data = res.data;
                var allck = true;
                for (i = 0; i < dataarr.length; i++) {
                    if (dataarr[i].status != 1 || dataarr[i].status == null) {
                        allck = false;
                        break;
                    }
                }
                if (!allck) {
                    $(".layui-table-header").find("input[name = 'layTableCheckbox'][lay-filter='layTableAllChoose']").each(function () {
                        $(this).attr("disabled", 'disabled').next().removeClass("layui-form-checked");
                        _this.form.render('checkbox');
                    });
                }
                var i = 0;
                $(".layui-table-body.layui-table-main").find("input[name='layTableCheckbox']").each(function () {
                    if (res.data[i].status != 1) {//关键点如果当前行数据中score包含57那么就不可选
                        $(this).attr("disabled", 'disabled').removeAttr("checked");
                        _this.form.render('checkbox');
                    }
                    i++;
                });

                i = 0;
                $(".layui-table-fixed.layui-table-fixed-l").find(".layui-table-body").find("input[name='layTableCheckbox']").each(function () {
                    if (res.data[i].status != 1) {//关键点如果当前行数据中score包含57那么就不可选
                        $(this).attr("disabled", 'disabled').removeAttr("checked");
                        _this.form.render('checkbox');
                    }
                    i++;
                });


            }

        });

        //监听工具条
        table.on('tool(orgsuylist)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                $("#hidorgid").val(data.orgid);
                $("#hidorgsummaryid").val(data.orgsummaryid);

                _this.OpTab(2, data);

                $("#table_title").html(data.orgname + " " + data.year + " 年  " + data.month + " 月交通补助表");

                _this.table = _this.InitTableByBt(data.orgid, data.orgsummaryid);
            } else if (obj.event === 'guidang') {
                top.mylayui.confirm('确定要归档吗？', {icon: 0}, function (index) {
                    top.mylayui.close(index);
                    vTransPay.updatestatus(data.orgsummaryid, 2);
                })
            } else if (obj.event === 'bohui') {
                top.mylayui.confirm('确定要驳回吗？', {icon: 0}, function (index) {
                    top.mylayui.close(index);
                    vTransPay.updatestatus(data.orgsummaryid, 3);
                })
            } else if (obj.event === 'shengcheng') {
                vTransPay.createatttb(data.orgid, data.year, data.month);
            }
        });

    });

    return table;
}

AttFjGd.prototype.SkipDetail = function (orgid, orgsummaryid, orgname, year, month) {
    $("#hidorgid").val(orgid);
    $("#hidorgsummaryid").val(orgsummaryid);
    this.OpTab(2);
    $("#table_title").html("房山公安分局" + orgname + " " + year + " 年  " + month + " 月交通补贴");
    this.table = this.InitTableByBt(orgid, orgsummaryid);
}

AttFjGd.prototype.querydetail = function () {
    if ($("#hidorgid").val() == "" || $("#hidorgid").val() == "0") {
        top.mylayui.msg('请先点机构列表后面详情按钮，再点击查询', {icon: 0});
        return;
    }


    this.InitTableByBt($("#hidorgid").val(), $("#hidorgsummaryid").val());
}


AttFjGd.prototype.InitTableByBt = function (orgid, orgsummaryid) {
    var table;
    var _this = this;
    layui.use('table', function () {
        table = layui.table;
        table.init('attfjgdlist', {
            height: $(window).height() - 205
            , url: 'get_tran_dept_list' // 数据接口
            , page: true // 开启分页
            , limit: 40
            , id: 'attfjgdlist'
            , limits: [20, 40, 80, 100]
            , method: "post"
            , request: {
                type: 'post'
            }
            , where: {
                year: '',
                mouth: '',
                orgid: orgid,
                orgsummaryid: orgsummaryid,
                realname: $("#realname").val()
            }
            , done: function (res, page, count) {

                var dataarr = res.data;
                $("[data-field='status']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        switch (text) {
                            case null:
                                $(this).text("未填报");
                                break;
                            case '':
                                $(this).text("未填报");
                                break;
                            case '0':
                                $(this).text("填报");
                                break;
                            case '1':
                                $(this).text("确认");
                                break;
                            case '2':
                                $(this).text("归档");
                                break;
                            case '3':
                                $(this).text("驳回");
                                break;
                            case '4':
                                $(this).text("审核通过");
                                break;
                        }
                    }
                })

                $("[data-field='sfqq']").children().each(function (index) {
                    if (index > 0) {
                        var text = $(this).text();
                        if (text == "0") {
                            $(this).text("否");
                        }
                        else {
                            $(this).text("是");
                        }
                    }
                })
//	                $("[data-field='sfjb']").children().each(function(index){ 
//			    		if(index>0){
//			    			var text=$(this).text();
//			    			if(text=="0"){
//			    				$(this).text("否");
//			    			}
//			    			else{
//			    				$(this).text("是");
//			    			}
//			    		}
//	               })

            }


        });


        //监听工具条
        table.on('tool(attfjgdlist)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                vTransPay.openadddetail(obj.data.attsummaryid, obj.data.orgsummaryid);
            }
        });


    })

    return table;


}

AttFjGd.prototype.save = function () {
    var tabledataJson = this.table.cache;
    var year = $("#year").val();
    var month = $("#month").val();
    tabledataJson['year'] = year;
    tabledataJson['month'] = month;
    tabledataJson = JSON.stringify(tabledataJson);
    tabledataJson = tabledataJson.replace(/LAY_TABLE_INDEX/g, 'lay_TABLE_INDEX');
    $.ajax({
        type: "POST",
        url: "update_tran_pay",
        contentType: 'application/json',
        data: tabledataJson,
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                top.mylayui.msg(data.msg, {icon: 1});
                vTransPay.querydetail();
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
        },
        complete: function (XHR) {

        },
        error: function () {

        }
    });
}

AttFjGd.prototype.createatttb = function (orgid, year, month) {


    var selectRow = $("#orgsuylist").ligerGrid().getSelecteds();
    if (selectRow.length == 0) {

        $.ajax({
            type: "POST",
            //url:"create_atttb",
            url: "create_tran_pay",
            data: {orgid: orgid, year: year, month: month},
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {


                    top.mylayui.msg(' 操作成功', {icon: 1});
                    vTransPay.searchlist();
                }
                else {
                    top.mylayui.msg('操作异常', {icon: 0});
                }


            },
            complete: function (XHR) {

            },
            error: function () {

            }
        });

    } else {

        var index = 0;
        for (var i = 0; i < selectRow.length; i++) {
            var element = selectRow[i];
            if (!element.status && element.__hasChildren == false) {


                $.ajax({
                    type: "POST",
                    //url:"create_atttb",
                    url: "create_tran_pay",
                    data: {orgid: element.orgid, year: element.year, month: element.month},
                    beforeSend: function (XHR) {
                        // top.ShowZheZhao();
                    },
                    success: function (data) {
                        index++;
                        data = eval('(' + data + ')');


                        if (index == selectRow.length) {


                            if (data.result > 0) {
                                top.mylayui.msg("操作成功", {icon: 1});
                                vTransPay.searchlist();
                            }
                            else {
                                top.mylayui.msg(data.msg, {icon: 0});
                            }
                            // top.ShowZheZhao();
                        }

                    },
                    complete: function (XHR) {
                        // top.ShowZheZhao();

                    },
                    error: function () {
                        // top.ShowZheZhao();
                    }
                });


            }


        }


    }


}


AttFjGd.prototype.openadddetail = function (attsummaryid, orgsummaryid) {
    top.mylayui.open({
        type: 2,
        title: '考勤详情',
        shadeClose: true,
        shade: 0.5,
        area: ['1000px', '500px'],
        content: 'attbmhz/att_bm_hz_show?attsummaryid=' + attsummaryid + "&orgsummaryid=" + orgsummaryid
    });
    var iframeele = top.$(".layui-layer-content").find('iframe');
    iframeele.css({"height": $(iframeele).height() - 10});
}

AttFjGd.prototype.addresult = function (result, msg) {
    if (result > 0) {
        top.mylayui.msg('操作成功', {icon: 1});
        top.mylayui.closeAll('iframe');
    }
    else {
        if (msg) {
            top.mylayui.msg(msg, {icon: 0});
        } else {
            top.mylayui.msg('操作失败', {icon: 0});
        }
    }
}

AttFjGd.prototype.searchtable = function () {
    this.table.reload('attfjgdlist', {
        page: {
            curr: 1 //重新从第 1 页开始
        }
        , where: {
            year: $("#year").val(),
            mouth: $("#mouth").val(),
            orgid: $("#orgid").val()
        }
    });
}

AttFjGd.prototype.searchtableorgsuy = function () {
    this.orgsuytable.reload('orgsuylist', {
        page: {
            curr: 1 //重新从第 1 页开始
        }
        , page: false
        , where: {
            year: $("#hidyear").val(),
            month: $("#hidmonth").val(),
            status: $("#hidstatus").val()
        }
    });
}

AttFjGd.prototype.searchlist = function () {
    this.grid.setOptions({
        newPage: 1, parms: {
            Method: "",
            year: $("#hidyear").val(),
            month: $("#hidmonth").val(),
            status: $("#hidstatus").val(),
            orgid: $("#hidorgid").val()
        }
    });
    this.grid.loadData();
}


AttFjGd.prototype.attrgd = function () {
    top.mylayui.confirm('确定要归档吗？', {icon: 0}, function () {
        $.ajax({
            type: "POST",
            url: "attr_fjgd",
            data: {
                year: $("#year").val(),
                mouth: $("#mouth").val(),
                orgid: $("#orgid").val()
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {
                    top.mylayui.msg(data.msg, {icon: 1});
                    vTransPay.searchtable();
                }
                else {
                    top.mylayui.msg(data.msg, {icon: 0});
                }
            },
            complete: function (XHR) {

            },
            error: function () {

            }
        });

    })
}


//AttFjGd.prototype.exportexcel=function(){
//	top.ShowZheZhao();
//	$.ajax({
//		type:"POST",
//		url:"export_excel",
//		data:{year: $("#year").val(),
//	    	mouth:$("#mouth").val(),
//	    	orgid:$("#orgid").val()},
//		beforeSend:function(XHR){
//			
//		},
//		success:function(data){
//			data=eval('('+data+')');
//			if(data.result>0){
//				//top.mylayui.msg(data.msg, {icon: 1});
//				//alert(data.msg);
//				window.open(data.msg,'_self');
//			}
//			else{
//				top.mylayui.msg(data.msg, {icon: 0});
//			}
//			top.ShowZheZhao();
//			
//		},
//		complete:function(XHR){
//			top.mylayui.closeAll('loading');
//		},
//		error:function(){
//			
//		}
//	});
//}

AttFjGd.prototype.exportexcel = function () {
    if ($("#hidorgid").val() == "" || $("#hidorgid").val() == "0") {
        top.mylayui.msg('请先点机构列表后面详情按钮，再点击查询', {icon: 0});
        return;
    }
    top.ShowZheZhao();
    $.ajax({
        type: "POST",
        url: "export_excel",
        data: {
            year: $("#year").val(),
            mouth: $("#month").val(),
            orgid: $("#hidorgid").val(),
            orgsummaryid: $("#hidorgsummaryid").val()
        },
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                //top.mylayui.msg(data.msg, {icon: 1});
                //alert(data.msg);
                window.open(data.msg, '_self');
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
            top.ShowZheZhao();

        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}


AttFjGd.prototype.exportexcelall = function () {

    top.ShowZheZhao();
    $.ajax({
        type: "POST",
        url: "export_excel_all",
        data: {
            year: $("#hidyear").val(),
            mouth: $("#hidmonth").val()
        },
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                //top.mylayui.msg(data.msg, {icon: 1});
                //alert(data.msg);
                window.open(data.msg, '_self');
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
            top.ShowZheZhao();

        },
        complete: function (XHR) {
            top.mylayui.closeAll('loading');
        },
        error: function () {

        }
    });
}


AttFjGd.prototype.updatestatus = function (orgsummaryid, status) {
    var constr = '确定要归档吗？';
    if (status == 2) {
        constr = '确定要归档吗？';
    }
    else if (status == 3) {
        constr = '确定要驳回吗？';
    }
    top.mylayui.confirm(constr, {icon: 0}, function (index) {
        top.mylayui.close(index);

        $.ajax({
            type: "POST",
            url: "update_tran_pay_status",
            data: {orgsummaryid: orgsummaryid, status: status},
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {
                    top.mylayui.msg(data.msg, {icon: 1});
                    //vTransPay.searchtableorgsuy();
                    vTransPay.searchlist();
                }
                else {
                    top.mylayui.msg(data.msg, {icon: 0});
                }
            },
            complete: function (XHR) {

            },
            error: function () {

            }
        });

    })


}


AttFjGd.prototype.updatestatusBm = function (orgsummaryids, status) {
    $.ajax({
        type: "POST",
        url: "update_tran_pay_statusbm",
        data: {orgsummaryids: orgsummaryids, status: status},
        beforeSend: function (XHR) {

        },
        success: function (data) {
            data = eval('(' + data + ')');
            if (data.result > 0) {
                top.mylayui.msg(data.msg, {icon: 1});
                //vTransPay.searchtableorgsuy();
                vTransPay.searchlist();
            }
            else {
                top.mylayui.msg(data.msg, {icon: 0});
            }
        },
        complete: function (XHR) {

        },
        error: function () {

        }
    });
}

AttFjGd.prototype.guidang = function () {
    var _this = this;
    top.mylayui.confirm('确定要归档吗？', {icon: 0}, function (index) {
        top.mylayui.close(index);
        var data = _this.grid.getCheckedRows();
        var length = data.length;
        if (length == 0) {
            top.mylayui.msg('请选择部门', {icon: 0});
            return;
        }
        var orgsummaryids = '';
        for (i = 0; i < length; i++) {
            var status = data[i].status;
            if(status == 1 || status == 0)//将可以归档的选择提报
                orgsummaryids += data[i].orgsummaryid + ',';
        }
        if (orgsummaryids.length == 0){
            top.mylayui.msg('所选部门不能归档', {icon: 0});
            return;
        }
        vTransPay.updatestatusBm(orgsummaryids, 2);
    })
}


var vTransPay = null;
$(function () {
    vTransPay = new AttFjGd();
})